#define quickread
#ifdef quickread
#include <cstdio> 
template <typename T>
inline void read(T& x)
{
    int c=getchar(), f=1; x=0;
    while(c<'0'||'9'<c) {if(c=='-') f=-1; c=getchar();}
    while('0'<=c&&c<='9') 
        x=(x<<3)+(x<<1)+c-'0', c=getchar();
    x*=f;
}
template <typename T>
inline void quickwrite(T x)
{
    if(x>=10) quickwrite(x/10);
    putchar(x%10+'0');
}
#else 
#include <iostream>
#endif
#include <vector>
#include <unordered_map>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
#define DEBUG
const int N=1e5+10;
vector<int> primes;
unordered_map<int, int> primepos;
int n;
int a[N], dp[N]; //dp[i]:以i为结尾的子串长度

void GetPrimes(int x, vector<int>& primes)
{
    primes.clear();
    for(int i=2; i<=sqrt(x); i++)
    {
        if(x%i==0) {
            primes.push_back(i);
            while(x%i==0) x/=i;
        }
    }

    if(x>1) primes.push_back(x);
}

void init()
{
    read(n);
    for(int i=1; i<=n; i++) read(a[i]);
    memset(dp, 1, sizeof dp); //以自身为起点和终点
}


void solve()
{
    init();
    vector<int> prime;

    for(int i=1; i<=n; i++)
    {
        GetPrimes(a[i], prime);
        int mxpos=0;
        for(int pri:prime) 
            if(primepos.count(pri)) mxpos=max(mxpos, primepos[pri]);

        dp[i]=mxpos+1;
        for(int p:prime) primepos[p]=max(primepos[p], dp[i]);      
    }
    quickwrite(*max_element(dp+1, dp+1+n)); puts("");
}

// #undef DEBUG
signed main()
{
    #ifdef DEBUG
        freopen("../in.txt", "r", stdin);
        freopen("../out.txt", "w", stdout);
    #endif
    #ifndef quickread
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #endif

    int T=1; //scanf("%d", &T);
    while(T--) 
    {
        solve();
    }
    return 0;
}